<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
    <title><?php echo $config['cfg_webname']; ?> - 修改信息</title>
    <link rel="stylesheet" type="text/css" href="css.css"/>
    <style type="text/css">
        #swfupload-control p {
            margin: 10px 5px;
            line-height: 25px;
            height: 25px;
            color: #666666;
            font-size: 12px;
        }

        #preview {
            margin: 0;
            padding: 0;
            width: 640px;
        }

        #preview li {
            list-style: none;
            margin: 2px;
            border: 1px solid #ccc;
            padding: 5px;
            font-size: 12px;
            font-family: Arial, Helvetica, sans-serif;
            color: #333;
            float: left;
            width: 140px;
            height: auto;
            background: #fff;
            position: relative;
        }

        #preview li .progressbar {
            border: 0px solid #333;
            height: 5px;
            margin-top: 3px;
            background: #fff;
        }

        #preview li .progress {
            background: #009900;
            width: 0%;
            height: 5px;
        }

        #preview li p {
            margin: 0;
            line-height: 18px;
        }

        #preview li.success {
            border: 1px solid #cccccc;
            background: #ffffff;
        }

        #preview li span.cancel {
            cursor: pointer;
        }

        #preview li .pic {
            width: 138px;
            height: 110px;
        }

        #preview li .pic img {
            width: 138px;
            height: 110px;
        }

        .textInput, .textInputC, .textInputP, .postTextarea {
            font-size: 14px;
            color: #555555;
            font-family: "Microsoft Yahei", "微软雅黑", Tahoma, Arial, Helvetica, STHeiti;
            _font-family: "微软雅黑";
            border: 1px solid #CCCCCC;
            float: left;
        }

        .textInput {
            line-height: 22px;
            height: 22px;
            padding: 2px;
            width: 365px;
        }

        .textInputC {
            line-height: 22px;
            height: 22px;
            padding: 2px;
            width: 100px;
        }

        .textInputP {
            line-height: 22px;
            height: 22px;
            padding: 2px;
            width: 180px;
        }

        .csSelect {
            position: relative;
            height: 22px;
            float: left;
            width: auto;
        }

        .csSelect div {
            float: left;
            width: auto;
        }

        .csSelect select {
            float: left;
            height: 22px;
            margin-right: 10px;
        }

        .postTextarea {
            padding: 4px;
        }

        .exLp {
            float: left;
            background-color: #dfdfdf;
            text-align: center;
            width: 40px;
            height: 28px;
            line-height: 28px;
            color: #000000;
            overflow: hidden;
        }
    </style>
    <script type="text/javascript" src="__THEME_PATH__js/m.js"></script>
</head>
<body>
<div align="center">

    <include file="Template/default/user/user_header.php"/>
    <script type="text/javascript" src="__THEME_PATH__js/swfupload.js"></script>
    <script type="text/javascript" src="__THEME_PATH__js/jquery.swfupload.js"></script>

    <script type="text/javascript">
        var s1;
        $(function () {
            $('#swfupload-control').swfupload({
                    upload_url: "{:U('info/post/uploadImg')}",
                    file_post_name: 'uploadfile',
                    file_size_limit: "10240",
                    file_types: "*.bmp;*.gif;*.jpg;*.jpeg;*.png",
                    file_types_description: "Image files",
                    file_upload_limit: 6,
                    flash_url: "__THEME_PATH__js/swfupload.swf",
                    button_image_url: '__THEME_PATH__images/button.png',
                    button_width: 114,
                    button_height: 30,
                    button_placeholder: $('#button')[0],
                    debug: false
                })
                .bind('fileQueued', function (event, file) {
                    var listitem = '<li id="' + file.id + '" >' +
                        '<div class="pic" id="pic' + file.id + '"></div>' +
                        '<div class="progressbar" ><div class="progress"></div></div>' +
                        '<p class="status" >等待上传 | <span class="cancel">删除</span></p>' +
                        '</li>';
                    $('#preview').append(listitem);
                    $('li#' + file.id + ' .cancel').bind('click', function () {
                        var swfu = $.swfupload.getInstance('#swfupload-control');
                        swfu.cancelUpload(file.id);
                        $('li#' + file.id).slideUp('fast');
                    });
                    // start the upload since it's queued
                    $(this).swfupload('startUpload');
                })
                .bind('fileQueueError', function (event, file, errorCode, message) {
                    if (errorCode == '-100') {
                        alert('最多可以上传6张图片！');
                    }
                    else {
                        alert('图片：【' + file.name + '】过大，单张图片请不要超过10.00M！');
                    }
                })
                .bind('fileDialogComplete', function (event, numFilesSelected, numFilesQueued) {
                    $('#queuestatus').text('');
                })
                .bind('uploadStart', function (event, file) {
                    $('#preview li#' + file.id).find('p.status').text('0%上传中...');
                    $('#preview li#' + file.id).find('span.cancel').hide();
                })
                .bind('uploadProgress', function (event, file, bytesLoaded) {
                    //Show Progress
                    var percentage = Math.round((bytesLoaded / file.size) * 100);
                    $('#preview li#' + file.id).find('div.progress').css('width', percentage + '%');
                    $('#preview li#' + file.id).find('p.status').text(percentage + '%上传中...');
                })
                .bind('uploadSuccess', function (event, file, serverData) {
                    var item = $('#preview li#' + file.id);
                    item.find('div.progress').css('width', '100%');
                    item.addClass('success').find('p.status').html('100%上传成功! | <span class="cancel" onclick="delPic(\'' + file.id + '\')">删除</span>');
                    _q("pic" + file.id).innerHTML = '<img src="' + serverData + '" id="img' + file.id + '" />';
                    _q("pic").value += serverData + ",";
                })
                .bind('uploadComplete', function (event, file) {
                    // upload has completed, try the next one in the queue
                    $(this).swfupload('startUpload');
                });
            if (_q("pic").value != "") {
                arrPic = _q("pic").value.split(",");
                var picCount = 0;
                for (t = 0; t < arrPic.length; t++) {
                    if (arrPic[t] != "") {
                        picCount++;
                        if(picCount >= 6){
                            document.getElementById("swfupload-control").removeChild();
                        }
                        _q("preview").innerHTML += '<li id="' + t + '" >' +
                            '<div class="pic" id="pic' + t + '"><img src="/UploadFiles/info/thum/600_600/' + arrPic[t] + '" id="img' + t + '" /></div>' +
                            '<div class="progressbar" ><div class="progress"></div></div>' +
                            '<p class="status" >100%上传成功! | <span class="cancel" onclick="delPic(\'' + t + '\')">删除</span></p>' +
                            '</li>';
                    }
                }
            }


        });

        function delPic(pid) {
            var picPath = _q("img" + pid).src;
            $('li#' + pid).slideUp('fast');
            var swfu = $.swfupload.getInstance('#swfupload-control');
            var stats = swfu.getStats();
            stats.successful_uploads--;
            swfu.setStats(stats);
            var picArr = _q("pic").value.split(',');
            _q("pic").value = "";
            for (i = 0; i < picArr.length; i++) {
                if (picPath.indexOf(picArr[i]) < 0) {
                    _q("pic").value += picArr[i] + ",";
                }
            }
        }
    </script>
    <div class="main" align="left">
        <div class="clear"></div>

        <include file="Template/default/user/user_left.php"/>
        <div class="userRight">
            <div class="userRightContent">
                <div class="userRightContentTop">修改“网站建设优惠”信息</div>
                <form action="{:U('User/manager/editeInfo',array('id'=>$info['id']))}" method="post" onsubmit="return valiPost('all')"
                      name="postmess"><input type="hidden" value="ea8a706c4c34a168" name="adminpassword"/><input
                        type="hidden" value="937186" name="id"/>
                    <table width="810" class="userMessTable" border="0" cellpadding="5" cellspacing="0">
                        <tr>
                            <td class="head" width="100"><span
                                    style="color:#FF0000; font-size:14px; padding:5px;">*</span>标题：
                            </td>
                            <td><input type="text" name="dyff89aso" id="dyff89aso" onblur="valiPost('exTitle')"
                                       class="textInput" value="<?php echo $info['title'];?>"/>
                                <div class="exDiv" id="exTitle"></div>
                                <input type="hidden" name="sort" value=""/></td>
                        </tr>
                        <tr>
                            <td class="head"><span style="color:#FF0000; font-size:14px; padding:5px;">*</span>地区：</td>
                            <td>
                                <div class="csSelect">
                                    <div><select name="address" onchange="acLoadAddress(this.value,'')" id="address">
                                            <option value="">请选择</option>
                                            <?php foreach ($area as $k => $v) { ?>
                                                <option value="<?php echo $k; ?>"
                                                    <?php if ($info['area'] == $k) {
                                                    echo 'selected="selected"';
                                                } ?>>
                                                    <?php echo $v; ?></option>
                                            <?php } ?>
                                        </select></div>
                                    <div id="divKfCity"></div>
                                    <script>function acLoadAddress(a, v) {
                                            //$("#divKfCity").load("/services/index.aspx?s=ajaxCity&city=" + a + "&name=address1&value=" + v);
                                        }</script>
                                </div>
                                <div class="exDiv" id="exAddress"></div>
                            </td>
                        </tr>
                        <tr>
                            <td class="head">联系人：</td>
                            <td><input type="text" name="name" id="name" onblur="valiPost('exName')" class="textInputP"
                                       value="<?php echo $info['linkman'];?>"/>
                                <div class="exDiv" id="exName"></div>
                            </td>
                        </tr>
                        <tr>
                            <td class="head">价格：</td>
                            <td><input type="text" name="price" id="price" onblur="valiPost('exPrice')"
                                       class="textInputP" style="width:140px;" value="<?php echo $info['money'];?>"/>
                                <div class="exLp">元</div>
                                <div class="exDiv" id="exPrice"></div>
                            </td>
                        </tr>

                        <tr>
                            <td class="head">上传图片：</td>
                            <td>
                                <div id="swfupload-control">
                                    <table width="100%" border="0">
                                        <tr>
                                            <td width="130"><input type="button" id="button"/></td>
                                            <td><span
                                                    style="line-height:40px; font-size:12px; color:#000000; letter-spacing:1px; color:#333333;">可一次上传最多<strong>6</strong>张图片，每张图片请小于10.00M。</span>
                                            </td>
                                        </tr>
                                    </table>
                                    <ul id="preview">



                                    </ul>
                                </div>
                                <input type="hidden" name="pic" id="pic" value="<?php echo $info['images'];?>"/></td>
                        </tr>
                        <tr>
                            <td class="head"><span style="color:#FF0000; font-size:14px; padding:5px;">*</span>内容：</td>
                            <td><textarea name="content" class="postTextarea" id="content"
                                          onblur="valiPost('exContent')" rows="6" cols="60"><?php echo $info['content'];?></textarea>
                                <div class="exDiv" id="exContent"></div>
                            </td>
                        </tr>
                        <tr>
                            <td class="head"><span style="color:#FF0000; font-size:14px; padding:5px;">*</span>联系方式：
                            </td>
                            <td>
                                <div class="exLp">手机</div>
                                <input type="text" name="tel" id="tel" onkeyup="preview()"
                                       onblur="valiPost('exContact')" class="textInputC" value="<?php echo $info['phone'];?>" size="12"/>
                                <div class="exLp">固话</div>
                                <input type="text" name="phone" id="phone" onblur="valiPost('exContact')"
                                       class="textInputC" value="<?php echo $info['tel'];?>" size="12"/>
                                <div class="exLp">QQ</div>
                                <input type="text" name="qq" id="qq" onblur="valiPost('exContact')" class="textInputC"
                                       value="<?php echo $info['qq'];?>" size="12"/>
                                <div class="exDiv" id="exContact"></div>
                            </td>
                        </tr>
                        <tr>
                            <td class="head"><span style="color:#FF0000; font-size:14px; padding:5px;">*</span>有效期：</td>
                            <td><input type="text" class="textInput" value="<?php echo ceil((strtotime($info['valid_date']) - time() ) / 86400);?>" style="width:60px;"
                                       onblur="valiPost('exOverDate')" id="overdate" name="overdate"/>
                                <div class="exLp">天</div>
                                <div class="exDiv" id="exOverDate"></div>
                            </td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td><input type="submit" class="postSubmit" value="确认修改信息"/></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<script language="javascript" type="text/javascript">
    _q("address").onchange = function () {
        valiPost('exAddress');
        acLoadAddress(this.value, '');
    }
    sort = "3";
    if (sort != "") {
        for (i = 0; i < document.postmess.address.options.length; i++) {
            if (document.postmess.address.options[i].value == sort) {
                document.postmess.address.options[i].selected = true;
            }
        }
    }
    acLoadAddress('3', '');
    var sOverDate = "30";
    if (sOverDate != "") {
        document.postmess.overdate.value = "30";
    }
    ;


    function valiPost(name) {
        try {
            setCookie("kTitle", _q("${DynamicForm}").value);
            setCookie("kAddress", _q("address").value);
            setCookie("kName", _q("name").value);
            setCookie("kPrice", _q("price").value);
            setCookie("kPic", _q("pic").value);
            setCookie("kContent", _q("content").value);
            setCookie("kTel", _q("tel").value);
            setCookie("kPhone", _q("phone").value);
            setCookie("kQq", _q("qq").value);
            setCookie("kOverDate", _q("overdate").value);
            setCookie("kAdminPassWord", _q("adminpassword").value);
        }
        catch (e) {
        }
        bRef = true;
        if (name == "exTitle" || name == "all") {
            if (_q("dyff89aso").value == "" || _q("dyff89aso").value.length > 50) {
                kflErr("exTitle", "标题50字以内！");
                bRef = false;
            }
            else {
                kflRig("exTitle");
            }
        }

        if (name == "exName" || name == "all") {
            if (_q("name").value.length > 5) {
                kflErr("exName", "5个字以内！如：张先生");
                bRef = false;
            }
            else {
                kflRig("exName");
            }
        }

        if (name == "exPrice" || name == "all") {
            if (_q("price").value != "" && !/^\d+[.]?\d*$/.test(_q("price").value)) {
                kflErr("exPrice", "请输入数字！");
                bRef = false;
            }
            else {
                kflRig("exPrice");
            }
        }

        if (name == "exContent" || name == "all") {
            if (_q("content").value == "" || _q("content").value.length > 1000) {
                kflErr("exContent", "请输入内容，1000字以内！");
                bRef = false;
            }
            else {
                kflRig("exContent");
            }
        }

        if (name == "exAddress" || name == "all") {
            if (_q("address").value == "") {
                kflErr("exAddress", "请选择所在地！");
                bRef = false;
            }
            else {
                kflRig("exAddress");
            }
        }

        if (name == "exOverDate" || name == "all") {
            if (_q("overdate").value == "" || !/^\d+$/.test(_q("overdate").value)) {
                kflErr("exOverDate", "请输入数字！");
                bRef = false;
            }
            else {
                kflRig("exOverDate");
            }
        }

        if (name == "exAdminPassWord" || name == "all") {
            if (_q("adminpassword").value == "" || _q("adminpassword").value.length > 16) {
                kflErr("exAdminPassWord", "请输入1-16位管理密码！");
                bRef = false;
            }
            else {
                kflRig("exAdminPassWord");
            }
        }

        if (name == "exContact" || name == "all") {
            if (_q("tel").value != "" && !/^\d{11}$/.test(_q("tel").value)) {
                kflErr("exContact", "请输入11位数字的手机号码");
                bRef = false;
            }
            else {
                kflRig("exContact");
                if (_q("phone").value != "" && _q("phone").value.length > 15) {
                    kflErr("exContact", "请输入15位以内的电话号	！");
                    bRef = false;
                }
                else {
                    kflRig("exContact");
                    if (_q("qq").value != "" && !/^\d{3,13}$/.test(_q("qq").value)) {
                        kflErr("exContact", "请输入13位以内的字数QQ号！");
                        bRef = false;
                    }
                    else {
                        kflRig("exContact");
                    }
                }
            }
            if (_q("tel").value == "" && _q("phone").value == "" && _q("qq").value == "") {
                kflErr("exContact", "至少填写一个联系方式！");
                bRef = false;
            }

        }
        if (name == "exAdminPassWord" || name == "all") {
            if (_q("adminpassword").value == "" || _q("adminpassword").value.length > 16) {
                kflErr("exAdminPassWord", "请输入1-16位管理密码！");
                bRef = false;
            }
            else {
                kflRig("exAdminPassWord");
            }
        }
        if (name == "exVali" || name == "all") {
            if (_q("vali") != null) {
                if (_q("vali").value == "") {
                    kflErr("exVali", "请输入正确答案！");
                    bRef = false;
                }
                else {
                    fValiSession("15", _q("vali").value, "exVali");
                }
            }
        }

        if (name == "exValiDate" || name == "all") {
            if (_q("validate") != null) {
                if (_q("validate").value == "") {
                    kflErr("exValiDate", "请输入验证码！");
                    bRef = false;
                }
                else {
                    fValiSession("9", _q("validate").value, "exValiDate");
                }
            }
        }
        return bRef;
    }

    function kflErr(name, value) {
        _q(name).className = "pexErr";
        _q(name).innerHTML = value;
    }
    function kflRig(name) {
        _q(name).className = "pexRig";
        _q(name).innerHTML = "";
    }
</script>
</body>
</html>
